home *** CD-ROM | disk | FTP | other *** search
- /*
- mod 10 18 86 tsh - LSC 1.41 version
- MOD 07-19-86 MAZ - converted from stdfile.c for lightspeedC
- */
-
- #include <PackageMgr.h>
- #include <FileMgr.h>
- #include <StdFilePkg.h>
- #include "MAZlib.h"
-
- /* standard file's last VRefNum */
- extern short SFVRefNum : 0x214;
-
- long filter_type = 0;
- long filter_type_2 = 0;
- long filter_creator = 0;
- short global_volrefnum;
-
- pascal Boolean filter(f)
- FileParam *f;
- {
- if (filter_creator != 0 && f->ioFlFndrInfo.fdCreator != filter_creator)
- return(TRUE);
- if (filter_type != 0 && f->ioFlFndrInfo.fdType != filter_type
- && (filter_type_2 == 0 || f->ioFlFndrInfo.fdType != filter_type_2))
- return(TRUE);
- return(FALSE);
- }
-
- bool input_file_name(prompt,filename)
- char *prompt;
- char filename[];
- {
- SFTypeList typeList;
- SFReply reply;
- char *p;
- Point loc;
- short i, len;
- char myprom[256];
- char myfile[256];
-
- i = strlen(prompt);
- cpybuf(myprom+1,prompt,i);
- myprom[0] = i;
- loc.v = 80;
- loc.h = 100;
- typeList[0] = filter_type;
- typeList[1] = filter_type_2;
- reply.vRefNum = 0;
- if (filter_type == 0)
- len = 0;
- else if (filter_type_2 == 0)
- len = 1;
- else
- len = 2;
- SFGetFile(loc, myprom, &filter, len, typeList, 0, &reply);
- global_volrefnum = SFVRefNum;
- if (!reply.good)
- return(false);
- global_volrefnum = reply.vRefNum;
- i = reply.fName[0];
- cpybuf(filename,reply.fName+1,i);
- filename[i] = '\0';
- return(true);
- }
-
- bool output_file_name(prompt,filename,suggested_name)
- char *prompt;
- char filename[];
- char *suggested_name;
- {
- SFReply reply;
- char *p;
- Point loc;
- short i;
- char myprom[256];
- char myfile[256];
-
- i = strlen(prompt);
- cpybuf(myprom+1,prompt,i);
- myprom[0] = i;
- i = strlen(suggested_name);
- cpybuf(myfile+1,suggested_name,i);
- myfile[0] = i;
- loc.v = 80;
- loc.h = 100;
- reply.vRefNum = 0;
- SFPutFile(loc, myprom, myfile, 0, &reply);
- global_volrefnum = SFVRefNum;
- if (!reply.good)
- return(false);
- global_volrefnum = reply.vRefNum;
- i = reply.fName[0];
- cpybuf(filename, reply.fName+1, i);
- filename[i] = '\0';
- return(true);
- }
-
- #define M68K_GetVolInfo 0XA007
-
- typedef struct
- {
- char header[12]; /* 0 */
- char *IOCompletion; /* 12 */
- short IOResult; /* 16 */
- char *IONamePtr; /* 18 (actually pascal string) */
- short IOVRefNum; /* 22 */
- long filler; /* 24-27 fields not used */
- short IOVolIndex; /* 28 */
- long IOVCrDate; /* 30 */
- long IOVLsBkUp; /* 34 */
- short IOVAtrb; /* 38 */
- short IOVNmFls; /* 40 */
- short IOVFDirSt; /* 42 */
- short IOVBlLen; /* 44 */
- short IOVNumAlBlks; /* 46 */
- long IOVAlBlkSiz; /* 48 */
- long IOVClpSiz; /* 52 */
- short IOAlBlSt; /* 56 */
- long IOVNxtFNum; /* 58 */
- short IOVFrBlk; /* 62 */
- } VolInfo; /* 64 bytes */
-
- get_vol_stuff(vrefnum,pattr,pblksize,pnblocks)
- short vrefnum;
- short *pattr;
- long *pblksize;
- short *pnblocks;
- {
- VolInfo parm;
-
- parm.IONamePtr = null;
- parm.IOVRefNum = vrefnum;
- parm.IOVolIndex = 0; /* use vrefnum only */
- parm.IOCompletion = null;
- PBGetVInfo(&parm,false);
- *pattr = parm.IOVAtrb;
- *pblksize = parm.IOVAlBlkSiz;
- *pnblocks = parm.IOVFrBlk;
- }
-
- long disk_bytes_free(vrefnum)
- short vrefnum;
- {
- short attr, nblocks;
- long blksize;
-
- get_vol_stuff(vrefnum,&attr,&blksize,&nblocks);
- return(blksize*nblocks);
- }
-